﻿using System;
using System.ServiceModel;
using System.Windows.Browser;
using SuperGo.Silverlight.WebApp;

namespace SuperGo.Silverlight {
	public abstract class GoService {
		public static GoServicesSoapClient GetGoServicesSoapClient() {
			return new GoServicesSoapClient(new BasicHttpBinding(), GetEndpoint());
		}

		/// <summary>
		/// Returns a local web services if we're in development, otherwise returns a production address.
		/// </summary>
		public static EndpointAddress GetEndpoint() {
			return new EndpointAddress(GetServerHostAddress());
		}

		public static string GetServerHostAddress() {
			Uri myPage = HtmlPage.Document.DocumentUri;

			if (myPage.Host == "localhost") {
				return "http://localhost/GnuGo/GoServices.asmx";
			}
			return "http://www.blueink.biz/SuperGo/GoServices.asmx";
		}
	}
}
